package com.example.myapplication;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity
{
      
      // Used to load the 'myapplication' library on application startup.
      static
      {
            System.loadLibrary("ndkdemo"); //在cmake里可以改名称
      }
      
      private JavaForC jni;
      TextView tv;
      
      
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            // Example of a call to a native method
           tv = findViewById(R.id.sample_text);
            tv.setText(stringFromJNI("java"));
            jni = new JavaForC();
            
      }
      
      /**
       * A native method that is implemented by the 'myapplication' native library,
       * which is packaged with this application.
       */
      public native String stringFromJNI(String s);
      
      public void doc(View view)
      {
            String str = stringFromJNI("====java=====");
            tv.setText(str);
            Toast.makeText(this, "输出4444", Toast.LENGTH_SHORT).show();
      }
      
      public void docCallJava(View view)
      {
          int i =  jni.callbackAdd();
          tv.setText("C调java后的返回值 " + i);
      }
}